JavaScript 56.7%
TypeScript 42.6%
1import { NextRequest, NextResponse } from "next/server";2import { prisma } from "@/lib/prisma";3import { loadVersionData } from "@/lib/storage";45export async function GET(6 request: NextRequest,7 { params }: { params: { id: string; versionId: string } }8) {9 const version = await prisma.fileVersion.findUnique({10 where: { id: params.versionId },11 include: { file: true },12 });1314 if (!version || version.fileId !== params.id) {15 return NextResponse.json({ error: "Version not found" }, { status: 404 });16 }1718 // Les versions sont des copies du fichier (même état de chiffrement que le fichier courant)19 const data = await loadVersionData(version.storagePath, version.file.isEncrypted);2021 return new NextResponse(new Uint8Array(data), {22 headers: {23 "Content-Type": "application/octet-stream",24 "Content-Disposition": `attachment; filename="${encodeURIComponent(version.file.name)}"`,25 "Content-Length": String(data.length),26 },27 });28}29